package com.mid;

/**
 * Created by Lxk on 2019/7/7.
 */
public class Solution240 {

    public boolean searchMatrix(int[][] matrix, int target) {
        if(matrix==null){
            return false;
        }
        if(matrix.length==0){
            return false;
        }
        if(matrix[0]==null){
            return false;
        }
        if(matrix[0].length==0){
            return false;
        }
        int posx = matrix[0].length-1,posy=0;
        while(posx>=0&&posy<=matrix.length-1){
            if(matrix[posy][posx]>target){
                posx--;
            }else if(matrix[posy][posx]<target){
                posy++;
            }else{
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Solution240 solution240 = new Solution240();
        int[][] matrix = new int[0][];
        solution240.searchMatrix(matrix,0);
    }

}
